﻿// WF框架UI初始化 create by alan 2013.04.25
function initUI()
{
    /*系統佈局*/
    WinSize();
    
    //插件裝載
    $("[plug='tooltip']").tooltip({placement:"bottom"});
    navTab.init();
    initTab();	
    
    /*菜單*/
    $(".menu .main li a").mouseover(function()
    {        
        $(".submenu").show();
        var href = $(this).attr('id');
        var offset = $(this).offset();
        var t = parseInt(offset.top-30);
        if ($(href).length > 0) 
        {
            $(".menu .main li a").removeClass('active');
            $(".submenu > div").hide();
            $(this).addClass('active');
            if($(href).length > 0)
            {
                $(".submenu").css({top:t});
                $(href).show();
            }
            
            $(".content").bind("mouseover",function(){$(".submenu").hide();});
            
            return false;
            
        }
        else
            $(".submenu").hide();
    });
};
var ws = {};
function WinSize()
{
    var wh = $(window).height();
    var ww = $(window).width();
    var top = $(".header").height();
    var left = $(".menu").width();
    var c_height = wh-top-4;
    var c_with = ww-left-8;
    $(".content").height(c_height).width(c_with);
    $(".content .tabsPageContent .page").height(c_height-30).width(c_with-1);
    ws.width = c_with-1;
    ws.height = c_height-30;
}

function initTab()
{
    $("[type='navtab']").each(function()
    {
        $(this).click(function(event)
        {
            var $this = $(this);
            var id = $this.attr("navid") || "";
            var title = $this.text() || "Page";
            var url = $this.attr("url") || "NoUrl.html";            
            navTab.openTab({id:id, url:url,title:title});
            event.preventDefault();
        });
    }); 
}

window.onresize = function(){
    WinSize();
};

